<template>
  <div class="loginWrap">
    <!--      标题-->
    <deliver-top-bar :title="'配送历史记录'" refresh @dorefresh="getList"></deliver-top-bar>
    <div style="padding: 5px 0 ;">
<!--      <xsearch :columns="searchFields" :model="searchModel"></xsearch>-->
    </div>
    <!--      车辆-->
    <div style="padding: 0 5px;">
      <t-grid :fields="columns" :data-list="list" :grid-height="gheight" @cellClick="cellClick" />
    </div>
    <el-dialog title="装车明细" v-model="showPop" esc-closable :height="600" :width="1000">
      <t-grid :data-list="list1" :fields="columns1" :grid-height="530" />
    </el-dialog>
  </div>
</template>
<script>
// 待配送列表
import tool from "@/utils/tool";
export default {
  name: "loadedHist",
  data () {
    return {
      searchFields: [
        { field: 'beginDate', title: '开始日期：', component: 'JPicker',width: 120 },
        { field: 'endDate', title: '结束日期：', component: 'JPicker',width: 120 },
        {field: 'searchTxt', title:'关键字',component: 'jinput', },
      ],
      searchModel: {
        beginDate: '',
        endDate: '',
        searchTxt: '',
      },
      columns: [
        {field: 'id', title: 'ID', visible: false},
        {field: '', type: 'index', width: 60},
        {field: 'billNo', title: '配送号',width: 120,className: 'canClick'  },
        {field: 'billDate', title: '配送日期',width: 100, align: 'center' },
        {field: 'licence', title: '车牌' ,width: 160,align: 'center',sortable: true },
        {field: 'driverName', title: '驾驶员' ,width: 140,align: 'center',sortable: true },
        {field: 'deliverNames', title: '送货员' ,width: 180,align: 'center',sortable: true },
        {field: 'ctime', title: '创建时间',width: 160 , sortable:true},
      ],
      list: [],
      gheight: window.innerHeight - 80,
      showPop: false,
      columns1: [
        {field: '', type: 'index', width: 60},
        {field: 'billNo', title: '票号',width: 120 },
        {field: 'billDate', title: '日期',width: 100, align: 'center' },
        {field: 'transTypeName', title: '业务类型' ,width: 110,align: 'center'  },
        {field: 'invName', title: '商品' ,align: 'left' },
        {field: 'unit', title: '单位' ,width: 50,align: 'center' },
        {field: 'qty', title: '数量' ,width: 60,align: 'right'  },
        {field: 'remark', title: '备注' ,width: 100,align: 'left'  },
      ],
      list1:[]
    }
  },
  created() {
    this.searchModel.beginDate = tool.getDay('', -1)
    this.searchModel.endDate = tool.getDay()
    this.getList()
  },
  methods: {
    getList () {
      tool.post('deliver/getHist', this.searchModel).then(ret => {
        if (ret.stat) {
          this.list = ret.data
        }
      })
    },
    cellClick (cell) {
      let column = cell.column
      let row = cell.row
      if (column.className === 'canClick') {
        tool.post('deliver/getCargoById', {id: row.id}).then(ret => {
          if(ret.stat) {
            this.list1 = ret.data
            this.showPop = true
          }
        })
      }
    }
  }
}
</script>
<style scoped>
.loginWrap {
  background-color: #f8f8f9;
}
</style>
